/*
 * JDialogImage.java
 *
 * Created on 12-may-2012, 10:54:27
 */
package com.ufps.cuatro.vistas.representacion;
 
import java.util.ArrayList;
import java.util.Observer;

import org.jdesktop.application.Action;

import com.ufps.cuatro.CuatroApp;
import com.ufps.cuatro.controlador.render.UtilRender;
import com.ufps.cuatro.modelo.representacion.MenuPane;
import com.ufps.cuatro.modelo.representacion.OptionMenuPane;
import com.ufps.cuatro.modelo.representacion.componente.ComponenteDistribuidor;
import com.ufps.cuatro.util.Bandera;
import com.ufps.cuatro.util.MessageWindow;
import com.ufps.cuatro.util.Utileria;
import com.ufps.cuatro.vistas.layout.JPanelExplorerTreeView;

/**
 *
 * @author Catc
 */
public class JDialogMenuContenedor extends javax.swing.JDialog implements MessageWindow{
    private static final long serialVersionUID = 4620237990680611593L;    
    
    private Object objParent;    
    private ArrayList<OptionMenuPane> objOptions;
    private String strTitle;
    private MenuPane objMenu;
    private ComponenteDistribuidor objComponenteDistribuidor;

    /** Creates new form JDialogImage */
    public JDialogMenuContenedor(java.awt.Frame parent, boolean modal) {
        super(parent, modal);
        initComponents();
        this.setIconImage(Utileria.leerIconoAppEnImagen(Utileria.MODO_16x16).getImage());
        this.objOptions = new ArrayList<OptionMenuPane>();
    }   
    
    public JDialogMenuContenedor(Object objParent) {
        super(CuatroApp.getApplication().getMainFrame(), true);
        initComponents();
        this.setIconImage(Utileria.leerIconoAppEnImagen(Utileria.MODO_16x16).getImage());
        this.objParent = objParent;        
        this.objOptions = new ArrayList<OptionMenuPane>();
    }
    
    public JDialogMenuContenedor(Object objParent, ComponenteDistribuidor objComponenteDistribuidor) {
        super(CuatroApp.getApplication().getMainFrame(), true);
        initComponents();
        this.jCheckBoxToolbar.setVisible(false);
        this.jComboBoxOrientation.setVisible(false);
        this.setIconImage(Utileria.leerIconoAppEnImagen(Utileria.MODO_16x16).getImage());
        this.objParent = objParent;        
        this.objComponenteDistribuidor = objComponenteDistribuidor;
        this.objMenu = objComponenteDistribuidor.getObjMenu();
        if(objMenu != null){
            strTitle = objMenu.getStrTitle();
            objOptions = objMenu.getObjOptions();
            jTextFieldName.setText(strTitle);
            UtilRender.helperRenderJList(jListAgregadas, objOptions, 0, javax.swing.ListSelectionModel.SINGLE_SELECTION);
        }                
        else{
            this.objOptions = new ArrayList<OptionMenuPane>();
        }
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel2 = new javax.swing.JLabel();
        jToolBar1 = new javax.swing.JToolBar();
        jButton1 = new javax.swing.JButton();
        jSeparator1 = new javax.swing.JToolBar.Separator();
        jButton3 = new javax.swing.JButton();
        jSeparator3 = new javax.swing.JToolBar.Separator();
        jButton4 = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();
        jTextFieldName = new javax.swing.JTextField();
        jLabel3 = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        jListAgregadas = new javax.swing.JList();
        jToolBar2 = new javax.swing.JToolBar();
        jButton2 = new javax.swing.JButton();
        jButton5 = new javax.swing.JButton();
        jSeparator6 = new javax.swing.JToolBar.Separator();
        jButtonUp = new javax.swing.JButton();
        jButtonUpAll = new javax.swing.JButton();
        jSeparator2 = new javax.swing.JToolBar.Separator();
        jButtonDown = new javax.swing.JButton();
        jButtonDownAll = new javax.swing.JButton();
        jSeparator4 = new javax.swing.JToolBar.Separator();
        jButton6 = new javax.swing.JButton();
        jCheckBoxToolbar = new javax.swing.JCheckBox();
        jComboBoxOrientation = new javax.swing.JComboBox();
        jLabel4 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Menu Asociado al Contenedor");
        setResizable(false);

        jLabel2.setBackground(new java.awt.Color(255, 255, 255));
        jLabel2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/ufps/cuatro/resources/icono app x 32.png"))); // NOI18N
        jLabel2.setText("<html><p><b>Generador de Menus:</b></p><p>Agregue o Elimine Opciones al Menu del Contenedor.</p>");
        jLabel2.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        jLabel2.setName("jLabel2"); // NOI18N
        jLabel2.setOpaque(true);

        jToolBar1.setFloatable(false);
        jToolBar1.setRollover(true);
        jToolBar1.setName("jToolBar1"); // NOI18N

        javax.swing.ActionMap actionMap = org.jdesktop.application.Application.getInstance().getContext().getActionMap(JDialogMenuContenedor.class, this);
        jButton1.setAction(actionMap.get("aceptar")); // NOI18N
        jButton1.setFocusable(false);
        jButton1.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jButton1.setName("jButton1"); // NOI18N
        jButton1.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jToolBar1.add(jButton1);

        jSeparator1.setName("jSeparator1"); // NOI18N
        jToolBar1.add(jSeparator1);

        jButton3.setAction(actionMap.get("cancelar")); // NOI18N
        jButton3.setFocusable(false);
        jButton3.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jButton3.setName("jButton3"); // NOI18N
        jButton3.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jToolBar1.add(jButton3);

        jSeparator3.setName("jSeparator3"); // NOI18N
        jToolBar1.add(jSeparator3);

        jButton4.setAction(actionMap.get("help")); // NOI18N
        jButton4.setFocusable(false);
        jButton4.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jButton4.setName("jButton4"); // NOI18N
        jButton4.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jToolBar1.add(jButton4);

        jLabel1.setText("Título:");
        jLabel1.setName("jLabel1"); // NOI18N

        jTextFieldName.setName("jTextFieldName"); // NOI18N

        jLabel3.setText("Lista de Opciones:");
        jLabel3.setName("jLabel3"); // NOI18N

        jScrollPane1.setName("jScrollPane1"); // NOI18N

        jListAgregadas.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
        jListAgregadas.setName("jListAgregadas"); // NOI18N
        jScrollPane1.setViewportView(jListAgregadas);

        jToolBar2.setFloatable(false);
        jToolBar2.setOrientation(javax.swing.SwingConstants.VERTICAL);
        jToolBar2.setName("jToolBar2"); // NOI18N

        jButton2.setAction(actionMap.get("incluir")); // NOI18N
        jButton2.setFocusable(false);
        jButton2.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jButton2.setName("jButton2"); // NOI18N
        jButton2.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jToolBar2.add(jButton2);

        jButton5.setAction(actionMap.get("excluir")); // NOI18N
        jButton5.setFocusable(false);
        jButton5.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jButton5.setName("jButton5"); // NOI18N
        jButton5.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jToolBar2.add(jButton5);

        jSeparator6.setName("jSeparator6"); // NOI18N
        jToolBar2.add(jSeparator6);

        jButtonUp.setAction(actionMap.get("up")); // NOI18N
        jButtonUp.setFocusable(false);
        jButtonUp.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jButtonUp.setName("jButtonUp"); // NOI18N
        jButtonUp.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jToolBar2.add(jButtonUp);

        jButtonUpAll.setAction(actionMap.get("upAll")); // NOI18N
        jButtonUpAll.setFocusable(false);
        jButtonUpAll.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jButtonUpAll.setName("jButtonUpAll"); // NOI18N
        jButtonUpAll.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jToolBar2.add(jButtonUpAll);

        jSeparator2.setName("jSeparator2"); // NOI18N
        jToolBar2.add(jSeparator2);

        jButtonDown.setAction(actionMap.get("downAll")); // NOI18N
        jButtonDown.setFocusable(false);
        jButtonDown.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jButtonDown.setName("jButtonDown"); // NOI18N
        jButtonDown.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jToolBar2.add(jButtonDown);

        jButtonDownAll.setAction(actionMap.get("down")); // NOI18N
        jButtonDownAll.setFocusable(false);
        jButtonDownAll.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jButtonDownAll.setName("jButtonDownAll"); // NOI18N
        jButtonDownAll.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jToolBar2.add(jButtonDownAll);

        jSeparator4.setName("jSeparator4"); // NOI18N
        jToolBar2.add(jSeparator4);

        jButton6.setAction(actionMap.get("limpiar")); // NOI18N
        jButton6.setFocusable(false);
        jButton6.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jButton6.setName("jButton6"); // NOI18N
        jButton6.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jToolBar2.add(jButton6);

        jCheckBoxToolbar.setText("Toolbar");
        jCheckBoxToolbar.setName("jCheckBoxToolbar"); // NOI18N

        jComboBoxOrientation.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "NORTH", "SOUTH", "EAST", "WEAST" }));
        jComboBoxOrientation.setEnabled(false);
        jComboBoxOrientation.setName("jComboBoxOrientation"); // NOI18N

        jLabel4.setText("Orientación:");
        jLabel4.setName("jLabel4"); // NOI18N

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, 308, Short.MAX_VALUE)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 241, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jToolBar2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
            .addGroup(layout.createSequentialGroup()
                .addComponent(jToolBar1, javax.swing.GroupLayout.DEFAULT_SIZE, 298, Short.MAX_VALUE)
                .addContainerGap())
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addComponent(jLabel1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jTextFieldName, javax.swing.GroupLayout.DEFAULT_SIZE, 254, Short.MAX_VALUE))
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                            .addComponent(jCheckBoxToolbar, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jLabel3, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel4)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jComboBoxOrientation, 0, 131, Short.MAX_VALUE)))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 70, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jToolBar1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(jTextFieldName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(1, 1, 1)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jCheckBoxToolbar)
                    .addComponent(jComboBoxOrientation, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel4))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel3)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addComponent(jToolBar2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.LEADING))
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(JDialogMenuContenedor.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(JDialogMenuContenedor.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(JDialogMenuContenedor.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(JDialogMenuContenedor.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the dialog */
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                JDialogMenuContenedor dialog = new JDialogMenuContenedor(new javax.swing.JFrame(), true);
                dialog.addWindowListener(new java.awt.event.WindowAdapter() {

                    @Override
                    public void windowClosing(java.awt.event.WindowEvent e) {
                        System.exit(0);
                    }
                });
                dialog.setVisible(true);
            }
        });
    }

    @Action
    public void aceptar() {
        if(objOptions.isEmpty()){
            msgWarning("Debe Ingresar al menos una Opción.");
            return;
        }
        if(jTextFieldName.getText().isEmpty()){
            msgWarning("Debe Ingresar un Nombre para el Menu.");
            return;
        }
        strTitle = jTextFieldName.getText();
        if(msgConfirm("¿Acepta el Menu Generado?")){
            Bandera objBandera = new Bandera();
            objBandera.addObserver((Observer) objParent);
            objBandera.setEstado(Bandera.MENU_CONTENEDOR);                
            objBandera.setFlag(true);
            if(objMenu == null){
                objMenu = new MenuPane(strTitle);                             
            } 
            else{
                objMenu.setStrTitle(strTitle);
            }
            objMenu.setMode(this.jCheckBoxToolbar.isSelected() ? MenuPane.TOOLBAR : MenuPane.MENU);
            objMenu.setOrientation(this.jComboBoxOrientation.getSelectedItem().toString());
            objMenu.setObjOptions(objOptions);
            objComponenteDistribuidor.setObjMenu(objMenu);
            objBandera.setObj(objMenu);
            objBandera.notificar();      
            dispose();
        }
    }

    @Action
    public void incluirImg() {        
    }

    @Action
    public void cancelar() {
        if(msgConfirm("¿Desea Cancelar el Proceso?")){
            Bandera objBandera = new Bandera();
            objBandera.addObserver((Observer) objParent);
            objBandera.setEstado(Bandera.PROCESO_CANCELADO);                
            objBandera.setFlag(false);
            objBandera.setObj(null);
            objBandera.notificar(); 
            dispose();
        }
    }

    @Action
    public void help() {
    }
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private javax.swing.JButton jButton4;
    private javax.swing.JButton jButton5;
    private javax.swing.JButton jButton6;
    private javax.swing.JButton jButtonDown;
    private javax.swing.JButton jButtonDownAll;
    private javax.swing.JButton jButtonUp;
    private javax.swing.JButton jButtonUpAll;
    private javax.swing.JCheckBox jCheckBoxToolbar;
    private javax.swing.JComboBox jComboBoxOrientation;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JList jListAgregadas;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JToolBar.Separator jSeparator1;
    private javax.swing.JToolBar.Separator jSeparator2;
    private javax.swing.JToolBar.Separator jSeparator3;
    private javax.swing.JToolBar.Separator jSeparator4;
    private javax.swing.JToolBar.Separator jSeparator6;
    private javax.swing.JTextField jTextFieldName;
    private javax.swing.JToolBar jToolBar1;
    private javax.swing.JToolBar jToolBar2;
    // End of variables declaration//GEN-END:variables

    public boolean msgConfirm(String strMsg) {
        if(objParent instanceof JPanelExplorerTreeView){
            JPanelExplorerTreeView objPanel = (JPanelExplorerTreeView) objParent;
            return UtilRender.msgConfirmar(strMsg, objPanel);            
        }
        else{
            return UtilRender.msgConfirmar(strMsg, this);            
        }        
    }

    public void msgInfo(String strMsg) {
        UtilRender.msgInformacion(strMsg, this);                    
    }

    public void msgWarning(String strMsg) {        
        UtilRender.msgAdvertencia(strMsg, this);                    
    }

    public void msgError(String strMsg) {        
        UtilRender.msgError(strMsg, this);                    
    }

    @Action
    public void incluir() {
        String str = UtilRender.leerEntradaTexto(this, "Ingrese una Opción de Menu:");
        if(str == null)return;
        if(str.isEmpty())return;
        OptionMenuPane objOptionMenuPane = new OptionMenuPane(str);
        objOptions.add(objOptionMenuPane);        
        UtilRender.helperRenderJList(jListAgregadas, objOptions, 0, javax.swing.ListSelectionModel.SINGLE_SELECTION);        
    }

    @Action
    public void excluir() {
        if(objOptions.isEmpty())return;
        if(jListAgregadas.isSelectionEmpty()){
            msgInfo("Debe Seleccionar una Opción.");
            return;
        }
        if(msgConfirm("¿Desea Eliminar la Opción Seleccionada?")){
            int i = jListAgregadas.getSelectedIndex();
            objOptions.remove(i);
            UtilRender.helperRenderJList(jListAgregadas, objOptions, 0, javax.swing.ListSelectionModel.SINGLE_SELECTION);        
        }
    }

    @Action
    public void limpiar() {
        if(objOptions.isEmpty())return;
        if(msgConfirm("¿Desea Eliminar las Opciones Ingresadas?")){
            objOptions.clear();
            UtilRender.helperRenderJList(jListAgregadas, objOptions, 0, javax.swing.ListSelectionModel.SINGLE_SELECTION);        
        }
    }

    @Action
    public void up() {
        if(jListAgregadas.isSelectionEmpty() && jListAgregadas.getSelectedIndex() == -1){
            UtilRender.msgInformacion("Debe Seleccionar una Opción.", this);
            return;
        }        
        int i = jListAgregadas.getSelectedIndex();
        OptionMenuPane objItemActual   = (OptionMenuPane) objOptions.get(i);
        OptionMenuPane objItemTemp     = (OptionMenuPane) objOptions.get(i - 1);        
        objOptions.set(i - 1, objItemActual);
        objOptions.set(i    , objItemTemp);
        UtilRender.helperRenderJList(jListAgregadas, objOptions, i - 1, javax.swing.ListSelectionModel.SINGLE_SELECTION);        
    }

    @Action
    public void upAll() {
        if(objOptions.isEmpty()){
            UtilRender.msgInformacion("No existen Opciones Agregadas.", this);
            return;
        }        
        else if((jListAgregadas.getSelectedIndex() == 0)){            
            return;
        }
        int i = jListAgregadas.getSelectedIndex();
        OptionMenuPane objItemActual   = (OptionMenuPane) objOptions.get(i);
        OptionMenuPane objItemTemp     = (OptionMenuPane) objOptions.get(0);        
        objOptions.set(0, objItemActual);
        objOptions.set(i    , objItemTemp);
        UtilRender.helperRenderJList(jListAgregadas, objOptions, 0, javax.swing.ListSelectionModel.SINGLE_SELECTION); 
    }

    @Action
    public void downAll() {
        if(objOptions.isEmpty()){
            UtilRender.msgInformacion("No existen Opciones Agregadas.", this);
            return;
        }       
        int maxI = objOptions.size() - 1;
        if((jListAgregadas.getSelectedIndex() == maxI)){            
            return;
        }
        int i = jListAgregadas.getSelectedIndex();
        OptionMenuPane objItemActual   = (OptionMenuPane) objOptions.get(i);
        OptionMenuPane objItemTemp     = (OptionMenuPane) objOptions.get(maxI);        
        objOptions.set(maxI, objItemActual);
        objOptions.set(i    , objItemTemp);
        UtilRender.helperRenderJList(jListAgregadas, objOptions, maxI, javax.swing.ListSelectionModel.SINGLE_SELECTION);        
    }

    @Action
    public void down() {
        if(jListAgregadas.isSelectionEmpty() && jListAgregadas.getSelectedIndex() == -1){
            UtilRender.msgInformacion("Debe Seleccionar una Opción.", this);
            return;
        }        
        int i = jListAgregadas.getSelectedIndex();
        OptionMenuPane objItemActual   = (OptionMenuPane) objOptions.get(i);
        OptionMenuPane objItemTemp     = (OptionMenuPane) objOptions.get(i + 1);        
        objOptions.set(i + 1, objItemActual);
        objOptions.set(i    , objItemTemp);
        UtilRender.helperRenderJList(jListAgregadas, objOptions, i + 1, javax.swing.ListSelectionModel.SINGLE_SELECTION);        
    }
}
